<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>jouyouyun&#39;s blog</title>
  <meta name="renderer" content="webkit" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">


<meta name="author" content="jouyouyun" /><meta name="description" content="jouyouyun&#39;s blog" /><meta name="keywords" content="jouyouyun, Hugo, theme, even" />






<meta name="generator" content="Hugo 0.54.0 with even 4.0.0" />


<link rel="canonical" href="https://jouyouyun.github.io/" />
  <link href="https://jouyouyun.github.io/index.xml" rel="alternate" type="application/rss+xml" title="jouyouyun&#39;s blog" />
  <link href="https://jouyouyun.github.io/index.xml" rel="feed" type="application/rss+xml" title="jouyouyun&#39;s blog" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/manifest.json">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">


<link href="/dist/even.93844dae.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.css" integrity="sha256-7TyXnr2YU040zfSP+rEcz29ggW4j56/ujTPwjMzyqFY=" crossorigin="anonymous">


<meta property="og:title" content="jouyouyun&#39;s blog" />
<meta property="og:description" content="jouyouyun&#39;s blog" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://jouyouyun.github.io/" />

<meta property="og:updated_time" content="2016-12-14T21:38:21&#43;08:00"/>

<meta itemprop="name" content="jouyouyun&#39;s blog">
<meta itemprop="description" content="jouyouyun&#39;s blog">

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="jouyouyun&#39;s blog"/>
<meta name="twitter:description" content="jouyouyun&#39;s blog"/>

<!--[if lte IE 9]>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/classlist/1.1.20170427/classList.min.js"></script>
<![endif]-->

<!--[if lt IE 9]>
  <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
<![endif]-->

</head>
<body>
  <div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/" class="logo">jouyouyun</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>
<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    <a href="/post/">
        <li class="mobile-menu-item">Archives</li>
      </a><a href="/tags/">
        <li class="mobile-menu-item">Tags</li>
      </a><a href="/categories/">
        <li class="mobile-menu-item">Categories</li>
      </a>
  </ul>
</nav>
  <div class="container" id="mobile-panel">
    <header id="header" class="header">
        <div class="logo-wrapper">
  <a href="/" class="logo">jouyouyun</a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    <li class="menu-item">
        <a class="menu-item-link" href="/post/">Archives</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/tags/">Tags</a>
      </li><li class="menu-item">
        <a class="menu-item-link" href="/categories/">Categories</a>
      </li>
  </ul>
</nav>
    </header>

    <main id="main" class="main">
      <div class="content-wrapper">
        <div id="content" class="content">
          <section id="posts" class="posts">
    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/mime-usage/">MIME Usage</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2016-12-14 </span>
      <div class="post-category">
          <a href="/categories/blog/"> BLOG </a>
          </div>
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <h2 id="基本使用">基本使用</h2>

<p>使用到的工具为: <code>xdg-mime, gvfs-mime</code></p>

<ul>
<li><p>查询文件的类型</p>

<p>使用 <code>xdg-mime query filetype &lt;filepath&gt;</code> 可以得到文件的类型</p></li>

<li><p>查询默认程序</p>

<p>使用 <code>xdg-mime query default text/plain</code> 或 <code>gvfs-mime --query &lt;mimetype&gt;</code>, <code>gvfs-mime</code> 还会列出支持此 <code>mimetype</code> 的所有程序</p></li>

<li><p>设置默认程序</p>

<p>如将 <code>text/plain</code> 的默认打开程序设置为 <code>gvim.desktop</code>, 可以执行 <code>xdg-mime default gvim.desktop text/plain</code> 或 <code>gvfs-mime --set text/plain gvim.desktop</code></p></li>
</ul>
    </div>
    <div class="read-more">
      <a href="/post/mime-usage/" class="read-more-link">阅读更多</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/xrandr-examples/">XRandr Examples</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2016-06-06 </span>
      <div class="post-category">
          <a href="/categories/note/"> NOTE </a>
          </div>
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <p>由于经常会用到使用 <code>xrandr</code> 设置屏幕属性, 而每次用的时候都要去查 <code>man</code> 手册, 有时还需要上网搜索例子.
这样一来就比较麻烦, 所以就想整理下 <code>xrandr</code> 的用法, 给出一些常用的例子.</p>

<h2 id="查询">查询</h2>

<p>使用 <code>xrandr -q</code> 命令可以查询当前的显示器状态, 使用 <code>xrandr --verbose</code> 将会显示更详细的信息.</p>
    </div>
    <div class="read-more">
      <a href="/post/xrandr-examples/" class="read-more-link">阅读更多</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/enable-coredump/">Enable Coredump</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2016-04-25 </span>
      <div class="post-category">
          <a href="/categories/blog/"> BLOG </a>
          </div>
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <h2 id="简介">简介</h2>

<p>当一个程序崩溃时会产生一个 <code>core</code> 文件, 里面记录了这个程序崩溃的原因, 这些信息对于开发者是很有用的.</p>

<p>但是 <code>core dumps</code> 在大多数 <code>linux</code> 上是被禁用的, 下面就介绍下如何开启这个功能.</p>

<h2 id="开启">开启</h2>

<p>可以通过 <code>ulimit -c</code> 的输出知道此功能是否开启, 输出为 <code>0</code> 表示禁用, 否则为开启.</p>

<h3 id="临时开启">临时开启</h3>

<p>通过 <code>ulimit -c unlimited</code> 命令来开启 <code>coredump</code> 功能, 它会程序运行的当前目录生成一个 <code>core</code> 文件, 新的 <code>core</code> 会覆盖旧的.</p>

<p>通过可以修改 <code>/proc/sys/kernel/core_uses_pid</code> 文件内容为 <code>1</code> 来生成以 <code>pid</code> 作为扩展名的 <code>core</code> 文件.</p>

<p>通过修改 <code>/proc/sys/kernel/core_pattern</code> 可以修改 <code>core</code> 文件的保存位置和格式. 如把内容改为 <code>/tmp/core-%e-%p-%t</code>, 就表示把 <code>core</code> 文件保存到 <code>/tmp</code> 目录下, 文件名的格式为 <code>core-命令名-pid-时间戳</code> .</p>
    </div>
    <div class="read-more">
      <a href="/post/enable-coredump/" class="read-more-link">阅读更多</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/auto-hidden-cursor/">Auto Hidden Cursor</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2016-04-22 </span>
      <div class="post-category">
          <a href="/categories/blog/"> BLOG </a>
          </div>
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <p>最近需要做一个隐藏光标的功能, 在这里将了解到的知识总结一下.</p>

<h2 id="原理">原理</h2>

<p>隐藏光标的原理就是把光标设置为一个 <code>x11 null cursor</code>, 不需要隐藏时再将它设为 <code>x11 left_ptr cursor</code>.</p>
    </div>
    <div class="read-more">
      <a href="/post/auto-hidden-cursor/" class="read-more-link">阅读更多</a>
    </div>
  </div>
</article>

    <article class="post">
  <header class="post-header">
    <h1 class="post-title"><a class="post-link" href="/post/debug-summary/">Debug 小结</a></h1>
    <div class="post-meta">
      <span class="post-time"> 2016-02-03 </span>
      <div class="post-category">
          <a href="/categories/note/"> NOTE </a>
          </div>
    </div>
  </header>
  
  <div class="post-content">
    <div class="post-summary">
      <p>调试 <code>bug</code> 的时候要有耐心, 要不断测试, 直到找到问题原因.</p>

<h2 id="基本思路">基本思路</h2>

<h3 id="确定-bug-出现的方式">确定 <code>bug</code> 出现的方式</h3>

<ul>
<li>一定要找到稳定重现的方式, 这样才能方便下面的调试</li>
<li>如果找不到稳定重现的方法就只能根据上次出现的情形, 去查看相关的代码, 猜测可能出问题的地方, 然后针对那一块进行调试, 直到找到稳定重现方式</li>
</ul>

<h3 id="定位出问题的代码">定位出问题的代码</h3>

<ul>
<li>再找到稳定重现方式后, 开始定位出问题的函数, 然后加入调试信息, 不断尝试, 直到找到有问题的代码</li>
<li>找到有问题的代码后, 如果发现是第三方库里的函数,可以打印出每次调用的输入输出参数, 看看是否有迹可循, 可以单独写个小程序, 传入问题的参数, 进行不断测试, 来确定第三方库有没有问题</li>
<li>如果自己程序的代码, 就一行一行的慢慢测试, 确定问题的原因, 原因找到了就可以开始思考解决方法了</li>
</ul>
    </div>
    <div class="read-more">
      <a href="/post/debug-summary/" class="read-more-link">阅读更多</a>
    </div>
  </div>
</article>

    </section>
  
  <nav class="pagination">
    <a class="prev" href="/page/6/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text">上一页</span>
      </a>
    <a class="next" href="/page/8/">
        <span class="next-text">下一页</span>
        <i class="iconfont icon-right"></i>
      </a>
  </nav>
        </div>
        

      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="social-links">
      <a href="mailto:jouyouwen717@gmail.com" class="iconfont icon-email" title="email"></a>
      <a href="https://twitter.com/jouyouyun" class="iconfont icon-twitter" title="twitter"></a>
      <a href="https://github.com/jouyouyun" class="iconfont icon-github" title="github"></a>
  <a href="https://jouyouyun.github.io/index.xml" type="application/rss+xml" class="iconfont icon-rss" title="rss"></a>
</div>

<div class="copyright">
  <span class="power-by">
    由 <a class="hexo-link" href="https://gohugo.io">Hugo</a> 强力驱动
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    主题 - 
    <a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
  </span>

  

  <span class="copyright-year">
    &copy; 
    2014 - 
    2019
    <span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">jouyouyun</span>
  </span>
</div>
    </footer>

    <div class="back-to-top" id="back-to-top">
      <i class="iconfont icon-up"></i>
    </div>
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/slideout@1.0.1/dist/slideout.min.js" integrity="sha256-t+zJ/g8/KXIJMjSVQdnibt4dlaDxc9zXr/9oNPeWqdg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.1.20/dist/jquery.fancybox.min.js" integrity="sha256-XVLffZaxoWfGUEbdzuLi7pwaUJv1cecsQJQqGLe7axY=" crossorigin="anonymous"></script>
<script type="text/javascript" src="/dist/even.ece58db6.min.js"></script>








</body>
</html>
